import yaml
import os
import jupytext



nb=jupytext.read('main.ipynb')


yaml.warnings({'YAMLLoadWarning':False}) 
f=open('config.yml','r',encoding='utf-8')

cfg=f.read()
lists=yaml.load(cfg)

folder='src'
nb_list=lists[folder]

context=''
info= folder+'\n'
for i, item in enumerate(nb_list):
    info=info+'   |--- '+item+'\n'
    with open(folder+'/'+item, 'w') as f:
        f.write(nb.cells[i]['source'])
print("Successfully sync\nmain.ipynb ->\n %s  " % info)


